# 804 简单：唯一的福尔摩斯词

# def uniqueMorseRepresentations(self, words: List[str]) -> int:
def uniqueMorseRepresentations(words) -> int:
    if len(words) < 2:
        return len(words)

    code = [
        ".-","-...","-.-.","-..",".","..-.","--.","....","..",
        ".---","-.-",".-..","--","-.","---",".--.","--.-",
        ".-.","...","-","..-","...-",".--","-..-","-.--","--.."
    ]

    s = set()

    for word in words:
        temp = ''
        for c in word:
            temp += code[ord(c) - 97]
        print(temp)
        s.add(temp)

    return len(s)

    # return len(set("".join(MORSE[ord(ch) - ord('a')] for ch in word) for word in words))


words = ["gin", "zen", "gig", "msg"]
print(uniqueMorseRepresentations(words))
